<?php if (!defined('THINK_PATH')) exit(); /*a:2:{s:43:"./themes/admin/dp/course_template_edit.html";i:1743994058;s:51:"/lysoo/syzth.lysoo.com/syzth/themes/admin/base.html";i:1741049647;}*/ ?>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title><?php echo $setup['title']; ?></title>
    <meta content="<?php echo $setup['keywords']; ?>" name="keywords" />
    <meta content="<?php echo $setup['description']; ?>" name="description" />
    <?php if($setup['ico'] != null): ?><link rel="shortcut icon" type="image/x-icon"  href="/public/uploads/<?php echo $setup['ico']; ?>"/><?php endif; ?>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/public/layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="/public/layuiadmin/style/admin.css" media="all">
    <!--CSS引用-->
    
    <!--页面CSS-->
    <!--[if lt IE 9]>
    <script src="/public/static/js/html5shiv.min.js"></script>
    <script src="/public/static/js/respond.min.js"></script>
    <![endif]-->
</head>
<body>

<div class="layui-fluid">
  <div class="layui-card">
    <div class="layui-tab layui-tab-brief">
      <ul class="layui-tab-title">
        <li><a href="<?php echo url('admin/dp/courseTemplate'); ?>">课程模板</a></li>
        <li class="layui-this">编辑模板</li>
      </ul>
      <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
          <form class="layui-form" action="<?php echo url('admin/dp/edit_course_template'); ?>" method="post">
            <input type="hidden" name="id" value="<?php echo $record['id']; ?>" />

            <div class="layui-form-item">
              <label class="layui-form-label">模板名称</label>
              <div class="layui-input-block">
                <input type="text" name="name" value="<?php echo $record['name']; ?>" required lay-verify="required" class="layui-input">
              </div>
            </div>

           <div class="layui-form-item">
  <label class="layui-form-label">专家</label>
  <div class="layui-input-block">
    <?php if(is_array($expert_list) || $expert_list instanceof \think\Collection || $expert_list instanceof \think\Paginator): if( count($expert_list)==0 ) : echo "" ;else: foreach($expert_list as $key=>$expert): ?>
<input type="checkbox" name="expert_ids[]" title="<?php echo $expert['name']; ?>" value="<?php echo $expert['id']; ?>" 
    <?php if(in_array($expert['id'], $record['expert_ids'])): ?>checked<?php endif; ?>>
    <?php endforeach; endif; else: echo "" ;endif; ?>
  </div>
</div>


            <div class="layui-form-item">
              <label class="layui-form-label">课程分类</label>
              <div class="layui-input-block">
                <select name="category_id" lay-verify="required">
                  <option value="">请选择分类</option>
                  <?php if(is_array($category_list) || $category_list instanceof \think\Collection || $category_list instanceof \think\Paginator): if( count($category_list)==0 ) : echo "" ;else: foreach($category_list as $key=>$cat): ?>
                    <optgroup label="<?php echo $cat['name']; ?>">
                      <?php if(is_array($cat['children']) || $cat['children'] instanceof \think\Collection || $cat['children'] instanceof \think\Paginator): if( count($cat['children'])==0 ) : echo "" ;else: foreach($cat['children'] as $key=>$sub): ?>
                      <option value="<?php echo $sub['id']; ?>" <?php if($record['category_id'] == $sub['id']): ?>selected<?php endif; ?>><?php echo $sub['name']; ?></option>
                      <?php endforeach; endif; else: echo "" ;endif; ?>
                    </optgroup>
                  <?php endforeach; endif; else: echo "" ;endif; ?>
                </select>
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">上课地点</label>
              <div class="layui-input-block">
                <input type="text" name="location" value="<?php echo $record['location']; ?>" required lay-verify="required" class="layui-input">
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">最大人数</label>
              <div class="layui-input-block">
                <input type="number" name="max_number" value="<?php echo $record['max_number']; ?>" required lay-verify="required" class="layui-input">
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">课程介绍</label>
              <div class="layui-input-block">
                <textarea name="desc" class="layui-textarea"><?php echo $record['desc']; ?></textarea>
              </div>
            </div>

            <div class="layui-form-item">
              <label class="layui-form-label">标题图</label>
              <div class="layui-input-inline">
                <input type="text" name="title_image" id="title_image" value="<?php echo $record['title_image']; ?>" class="layui-input">
              </div>
              <button type="button" class="layui-btn" id="upload_title">上传</button>
            </div>
            <?php if($record['title_image']): ?>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <img src="<?php echo $record['title_image']; ?>" style="max-height:100px;">
              </div>
            </div>
            <?php endif; ?>

            <div class="layui-form-item">
              <label class="layui-form-label">海报图</label>
              <div class="layui-input-inline">
                <input type="text" name="poster_image" id="poster_image" value="<?php echo $record['poster_image']; ?>" class="layui-input">
              </div>
              <button type="button" class="layui-btn" id="upload_poster">上传</button>
            </div>
            <?php if($record['poster_image']): ?>
            <div class="layui-form-item">
              <div class="layui-input-block">
                <img src="<?php echo $record['poster_image']; ?>" style="max-height:100px;">
              </div>
            </div>
            <?php endif; ?>

            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" lay-submit lay-filter="submitTplEdit">提交</button>
              </div>
            </div>

          </form>
        </div>
      </div>
    </div>
  </div>
</div>

<!--页面-->

<!--JS引用-->
<script src="/public/static/js/jquery.min.js"></script>
<script src="/public/layuiadmin/layui/layui.js"></script>
<script>
    layui.config({
        base: '/public/layuiadmin/' //静态资源所在路径
    }).extend({
        index: "lib/index" //主入口模块
    }).use('index');
</script>

<script>
layui.use(['form', 'upload'], function(){
  var form = layui.form, upload = layui.upload;

  upload.render({
    elem: '#upload_title',
    url: '/index/index/upload',
    field: 'file',
    done(res) {
      if (res.code === 1) {
        const url = '/public/' + res.data.url;
        $('#title_image').val(url);
        layer.msg('上传成功');
      } else {
        layer.msg('上传失败');
      }
    }
  });

  upload.render({
    elem: '#upload_poster',
    url: '/index/index/upload',
    field: 'file',
    done(res) {
      if (res.code === 1) {
        const url = '/public/' + res.data.url;
        $('#poster_image').val(url);
        layer.msg('上传成功');
      } else {
        layer.msg('上传失败');
      }
    }
  });

  form.on('submit(submitTplEdit)', function(data){
    $.post(data.form.action, $(data.form).serialize(), function(res){
      layer.msg(res.msg);
      if (res.code === 1) {
        setTimeout(() => location.href = "<?php echo url('admin/dp/courseTemplate'); ?>", 1000);
      }
    });
    return false;
  });
});
</script>

<!--页面JS脚本-->
</body>
</html>

